package com.shen;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

/**
 * Author:shen
 * CreateDate:2020/6/1.
 * Function:
 */
public class demo03 {
    static Scanner scanner=new Scanner(System.in);

   static  Calendar userCalendar=Calendar.getInstance();//用户生日
   static  Calendar systemCalendar=Calendar.getInstance();//当前系统时间
    public static void main(String[] args) {
        //获得现在的时间
        systemCalendar.getTime();
        Calendar nextCalendar=Calendar.getInstance();
        System.out.println("请输入您的出生日期：");
        System.out.println("月：");
        int moth=scanner.nextInt();
        System.out.println("日：");
        int date=scanner.nextInt();
        userCalendar.set(Calendar.MONTH,(moth-1));
        userCalendar.set(Calendar.DATE,date);
        getDate(userCalendar);
    }
    public static void getDate(Calendar userCalendar)  {

        int i = userCalendar.compareTo(systemCalendar);
        System.out.println(i);

        if(i==0){
            System.out.println("今天就是您的生日");
        }

        if(i>=1){
            long l = ( userCalendar.getTimeInMillis() -systemCalendar.getTimeInMillis())/(1000*60*60*24);
            System.out.println("您距离下一次的生日还有"+l+"天");
        }
        if(i<=-1){
            systemCalendar.add(Calendar.YEAR,1);
            long l =(systemCalendar.getTimeInMillis()- userCalendar.getTimeInMillis()) /(1000*60*60*24);
            System.out.println("您距离下一次的生日还有"+l+"天");
        }
    }
}
